<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<%String ctx=request.getContextPath();%>
<head>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
<meta http-equiv="description" content="This is my page"/>
<title>新闻管理系统--管理后台</title>
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@include file="console_element/top.jsp" %>
<div id="main">
  <%@include file="console_element/left.html" %>
  <div id="opt_area">
    <script language="javascript">
	function clickdel(){
		return confirm("删除请点击确认");
	}
</script>
    <ul class="classlist">
        <c:choose>
            <c:when test="${sessionScope.admin==null}">
                <jsp:forward page="/LoginServlet?opr=login"></jsp:forward>
            </c:when>
            <c:when test="${sessionScope.topicNewsList==null}">
                <jsp:forward page="/NewsServlet?opr=list"></jsp:forward>
            </c:when>
            <c:otherwise>
                <c:set var="n" value="0"></c:set>
                <c:forEach items="${sessionScope.topicNewsList}" var="news">
                    <c:set var="n" value="n+1"></c:set>
                    <li>${news.ntitle}<span>作者：${news.nauthor} &#160;&#160;&#160;&#160;
                        <a href="<%=ctx%>/NewsServlet?opr=findNews&nid=${news.nid}">修改</a> &#160;&#160;&#160;&#160;
                        <a href="<%=ctx%>/NewsServlet?opr=deleteNews&nid=${news.nid}" onclick="return clickdel()">删除</a></span></li>
                    <c:if test="n%5==0">
                        <li class='space'></li>
                    </c:if>
                </c:forEach>
            </c:otherwise>
        </c:choose>
    </ul>

      <div class="pager">
          <ul class="clearfix">
              <c:if test="${sessionScope.page.totalPage>1}">
                  <li><a href="${pageContext.request.contextPath}/NewsServlet?opr=list&currentPage=1">首页</a></li>
                  <c:choose>
                      <c:when test="${sessionScope.page.currentPage>=3}">
                          <li>...</li>
                          <!--上一页页码编号-->
                          <li><a href="${pageContext.request.contextPath}/NewsServlet?opr=list&currentPage=${sessionScope.page.currentPage-1}">${sessionScope.page.currentPage-1}</a></li>
                      </c:when>
                      <c:when test="${sessionScope.page.currentPage>=2}">
                          <!--上一页页码编号-->
                          <li><a href="${pageContext.request.contextPath}/NewsServlet?opr=list&currentPage=${sessionScope.page.currentPage-1}">${sessionScope.page.currentPage-1}</a></li>
                      </c:when>
                  </c:choose>
                  <li class="current">${sessionScope.page.currentPage}</li><!--当前页码编号-->
                  <c:choose>
                      <c:when test="${sessionScope.page.currentPage+1<sessionScope.page.totalPage}">
                          <!--下一页页码编号-->
                          <li><a href="${pageContext.request.contextPath}/NewsServlet?opr=list&currentPage=${sessionScope.page.currentPage+1}">${sessionScope.page.currentPage+1}</a></li>
                          <li>...</li>
                      </c:when>
                      <c:when test="${sessionScope.page.currentPage+1<=sessionScope.page.totalPage}">
                          <!--下一页页码编号-->
                          <li><a href="${pageContext.request.contextPath}/NewsServlet?opr=list&currentPage=${sessionScope.page.currentPage+1}">${sessionScope.page.currentPage+1}</a></li>
                      </c:when>
                  </c:choose>
                  <li><a href="${pageContext.request.contextPath}/NewsServlet?opr=list&currentPage=${sessionScope.page.totalPage}">尾页</a></li>
              </c:if>
          </ul>

      </div>


  </div>
</div>
<div id="footer">
  <%@include file="console_element/bottom.html" %>
</div>
</body>
</html>
